<template>
    <div>
        <div><button @click="isShow = !isShow">显示/隐藏</button></div>
        <!-- <transition name="feature"> -->
        <transition @before-enter="beforeEnter"
                    @enter="enter"
                    @after-enter="afterEnter"
                    @before-leave="beforeLeave"
                    @leave="leave"
                    @after-leave="afterLeave">
          <h2 class="title" v-if="isShow">Hello World</h2>
        </transition>
    </div>
</template>

<script>
    import gsap from 'gsap';

    export default {
        data() {
            return {
                isShow: true
            }
        },
        methods: {
            // 生命周期钩子
            // beforeEnter() {
            //     console.log('beforeEnter');
            // },
            // enter() {
            //     console.log('enter');
            // },
            // afterEnter() {
            //     console.log('afterEnter');
            // },
            // beforeLeave() {
            //     console.log('beforeLeave');
            // },
            // leave() {
            //     console.log('leave');
            // },
            // afterLeave() {
            //     console.log('afterLeave');
            // },
            enter(el, done) {
                gsap.from(el, {
                    scale: 0,
                    x: 200,
                    onComplete: done
                })
            },
            leave(el, done) {
                gsap.to(el, {
                    scale: 0,
                    x: 200,
                    onComplete: done
                })
            }

        }
    }
</script>

<style scoped>
    .title {
        display: inline-block;
    }

   

</style>